<template>
  <div class="app">
     <!-- navbar组件 -->
     <van-nav-bar
      title="我的收货地址"
      left-text="返回"
      right-text="新增地址"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <!-- 地址列表 -->
   <div class="addressbox">
    <div class="list" v-for="(item,index) in addresslist" :key="index">
      <div class="text">
         <h4> {{item.address||item.province+item.county+item.addressDetail}}</h4>
      <p><span>{{item.name}}</span> <span>{{item.tel||item.phone}}</span></p>
      </div>
     <button @click="$router.push({path:'/edit_address',query:{name:item.name,id:item.id}})"><van-icon name="edit" size="25" /></button>
    </div>
   </div>


  </div>
</template>

<script>
import { mapState} from 'vuex';
export default {
  data() {
    return {
    }
  },
  computed:{
    ...mapState(['addresslist'])
  },
  methods:{
    onClickLeft(){
      this.$router.go(-1)
    },
    onClickRight(){
      this.$router.push('/add_address')
    }
  }
}
</script>

<style lang="scss" scoped>

.list{
  width: 100%;
  height: 80px;
  display: flex;
  padding: 20px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e8e6e6;
  box-sizing: border-box;
  .text{
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    span{
    color: gray;
    margin-right: 10px;
  }
  }
  button{
    color: rgb(63, 175, 219);
    border: none;
    background: white;
  }
 
}
</style>